package com.avo.ramcache.orm;

import com.avo.ramcache.orm.impl.HibernateAccessor;
import com.avo.ramcache.orm.impl.HibernateQuerier;
import com.avo.ramcache.orm.impl.m2s.M2SHibernateAccessor;
import com.avo.ramcache.orm.impl.m2s.M2SHibernateQuerier;
import org.hibernate.SessionFactory;

public enum MappingModel {

    /**
     * single 2 single 单库 单连接池
     */
    S2SModel() {
        @Override
        public Accessor createAccessor(SessionFactory sessionFactory) {
            return super.createAccessor(sessionFactory);
        }

        @Override
        public Querier createQuerier(SessionFactory sessionFactory) {
            return super.createQuerier(sessionFactory);
        }
    },

    /**
     * multiple 2 single 多库 单连接池
     */
    M2SModel() {
        @Override
        public Accessor createAccessor(SessionFactory sessionFactory) {
            return new M2SHibernateAccessor(sessionFactory);
        }

        @Override
        public Querier createQuerier(SessionFactory sessionFactory) {
            return new M2SHibernateQuerier(sessionFactory);
        }
    };

    public Accessor createAccessor(SessionFactory sessionFactory) {
        return new HibernateAccessor(sessionFactory);
    }

    public Querier createQuerier(SessionFactory sessionFactory) {
        return new HibernateQuerier(sessionFactory);
    }
}